<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="常见问题">
<style>
    .button-large {
        font-size: 16px;
    }

    .webuploader-pick {
        background: none;
        padding: 0;
    }

    input.calendar {
        width: 160px;
    }
</style>
<div class="xm-product">
    <div class="row">
        <div class="panel">
            <div class="panel-header">
                <a href="${basepath}/rest/manage/question/toList">返回上一级</a>
            </div>
            <div class="panel-body">
                <form id="addForm" class="form-horizontal" action="${basepath}/rest/manage/question/insertJson"
                      method="post">
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            问题名称：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="name" placeholder="请输入名称"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            所在分类：
                        </label>
                        <div class="controls">
                            <select name="categoryID" class="category select-box pull-left"  data-rules="{required : true}">
                                <option value="">请选择分类</option>
                                </select>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            对应解答：
                        </label>
                        <div class="controls  control-row-auto">
                            <textarea name="answer"  class="control-row4 input-large" data-rules="{required : true}" placeholder="请输入内容"></textarea>
                        </div>
                    </div>
                    <div class="centered">
                        <button type="submit" class="button  button-large  button-success">保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    var addForm = new BUI.Form.Form({
        srcNode: '#addForm',
        submitType: 'ajax',
        callback: function (data) {
            if (data.success == true) {
                window.location.href = "${basepath}/rest/manage/question/toList"
            } else {
                BUI.Message.Alert(data.message, 'error');
                return;
            }
        }
    }).render();

    (function () {
        $.ajax({
            type:'GET',
            url:' /rest/manage/questioncategory/selectAllList',
            dataType:'json',
            success:function (data) {
                var list=data.data,html='';
                $.each(list,function (i, e) {
                    html+='<option value="'+e.id+'">'+e.name+'</option>'
                });
                $('.category').append(html);
            }
        })
    })();

</script>

</@page.pageBase>
